<script setup>
import { reactive, ref } from 'vue'
import router from '../router';
import { useRoute } from 'vue-router'
import { useRouter } from 'vue-router'
import { findByIdService } from '@/api/notice'


const toHome = () => {
    router.push('/')
}


const route = useRoute()
const id = route.query.id;
const type = route.query.type

const detail = reactive({
    tittle: '',
    time: null,
    content: ''
})

const showDetail = async () => {
    let result = await findByIdService(id)
    detail.tittle = result.data.tittle
    detail.time = result.data.time.slice(0, 10)
    detail.content = result.data.content
}
showDetail()

const router2 = useRouter()
const toMoreNotice = () => {
    router2.push({ path: '/moreNotice', query: { 'type': type} })
}
</script>



<template>
    <div style="padding: 30px;">
        <span v-if="type === null" style="color: gray;cursor: pointer;font-size: 20px;" @click="toHome">
            <el-icon>
                <DArrowLeft />
            </el-icon>返回首页
        </span>
        <span v-if="!(type === null)" style="color: gray;cursor: pointer;font-size: 20px;" @click="toMoreNotice">
            <el-icon>
                <DArrowLeft />
            </el-icon>返回
        </span>
    </div>
    <div style="padding-left: 250px;padding-right: 250px;">
        <h1 style="padding: 30px;text-align: center;color:#a13838">{{ detail.tittle }}</h1>
        <div style="text-align: center;margin-left: 400px;padding-bottom: 30px;">{{ detail.time }}</div>
        <div v-html="detail.content"></div>
    </div>

</template>